home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / c / ctags.lha / ctags-3.0.3 / debug.c < prev    next >
C/C++ Source or Header  |  1999-02-17  |  3KB  |  137 lines

  1. /*****************************************************************************
  2. *   $Id: debug.c,v 7.1 1998/12/07 01:38:00 darren Exp $
  3. *
  4. *   Copyright (c) 1996-1998, Darren Hiebert
  5. *
  6. *   This source code is released for free distribution under the terms of the
  7. *   GNU General Public License.
  8. *
  9. *   This module contains debugging functions.
  10. *****************************************************************************/
  11.  
  12. /*============================================================================
  13. =   Include files
  14. ============================================================================*/
  15. #include "general.h"
  16.  
  17. #include <ctype.h>
  18. #ifdef ENABLE_STDARG
  19. # include <stdarg.h>
  20. #else
  21. # include <varargs.h>
  22. #endif
  23.  
  24. #include "debug.h"
  25. #include "options.h"
  26. #include "read.h"
  27.  
  28. /*============================================================================
  29. =   Function definitions
  30. ============================================================================*/
  31.  
  32. #ifdef DEBUG
  33.  
  34. extern void lineBreak() {}    /* provides a line-specified break point */
  35.  
  36. #ifdef ENABLE_STDARG
  37. extern void debugPrintf( const enum eDebugLevels level,
  38.              const char *const format, ... )
  39. #else
  40. extern void debugPrintf( va_alist )
  41.     va_dcl
  42. #endif
  43. {
  44.     va_list ap;
  45.  
  46. #ifdef ENABLE_STDARG
  47.     va_start(ap, format);
  48. #else
  49.     enum eDebugLevels level;
  50.     const char *format;
  51.  
  52.     va_start(ap);
  53.     level = va_arg(ap, enum eDebugLevels);
  54.     format = va_arg(ap, char *);
  55. #endif
  56.  
  57.     if (debug(level))
  58.     vprintf(format, ap);
  59.     fflush(stdout);
  60.  
  61.     va_end(ap);
  62. }
  63.  
  64. extern void debugPutc( c, level )
  65.     const int c;
  66.     const int level;
  67. {
  68.     if (debug(level)  &&  c != EOF)
  69.     {
  70.              if (c == STRING_SYMBOL)    printf("\"string\"");
  71.         else if (c == CHAR_SYMBOL)    printf("'c'");
  72.     else                putchar(c);
  73.  
  74.     fflush(stdout);
  75.     }
  76. }
  77.  
  78. extern void debugParseNest( increase, level )
  79.     const boolean increase;
  80.     const unsigned int level;
  81. {
  82.     debugPrintf(DEBUG_PARSE, "<*%snesting:%d*>", increase ? "++" : "--", level);
  83. }
  84.  
  85. extern void debugCppNest( begin, level )
  86.     const boolean begin;
  87.     const unsigned int level;
  88. {
  89.     debugPrintf(DEBUG_CPP, "<*cpp:%s level %d*>", begin ? "begin":"end", level);
  90. }
  91.  
  92. extern void debugCppIgnore( ignore )
  93.     const boolean ignore;
  94. {
  95.     debugPrintf(DEBUG_CPP, "<*cpp:%s ignore*>", ignore ? "begin":"end");
  96. }
  97.  
  98. extern void clearString( string, length )
  99.     char *const string;
  100.     const int length;
  101. {
  102.     int i;
  103.  
  104.     for (i = 0 ; i < length ; ++i)
  105.     string[i] = '\0';
  106. }
  107.  
  108. extern void debugEntry( tag )
  109.     const tagEntryInfo *const tag;
  110. {
  111.     const char *const scope = tag->isFileScope ? "{fs}" : "";
  112.  
  113.     if (debug(DEBUG_PARSE))
  114.     {
  115.     unsigned int i;
  116.  
  117.     printf("<#%s%s:%s", scope, tag->kindName, tag->name);
  118.  
  119.     /*  Add any other extension flags.
  120.      */
  121.     for (i = 0  ;  i < tag->otherFields.count  ;  ++i)
  122.     {
  123.         const char *const label = tag->otherFields.label[i];
  124.         const char *const value = tag->otherFields.value[i];
  125.  
  126.         if (label != NULL)
  127.         printf("[%s:%s]", label, value == NULL ? "" : value);
  128.     }
  129.     printf("#>");
  130.     fflush(stdout);
  131.     }
  132. }
  133.  
  134. #endif
  135.  
  136. /* vi:set tabstop=8 shiftwidth=4: */
  137.